﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace CQIE.JonJack.MQList
{
    public class IMQSubject
    {
        //监听对象列表
        protected List<IMQObserver> observerList=new List<IMQObserver>();
        /// <summary>
        /// 增加一个监听对象
        /// </summary>
        /// <param name="mQObserver"></param>
        public void addAObserver(IMQObserver mQObserver)
        {
            this.observerList.Add(mQObserver);
        }
        /// <summary>
        /// 删除一个监听对象
        /// </summary>
        /// <param name="mQObserver"></param>
        public void DelAObserver(IMQObserver mQObserver)
        {
            this.observerList.Remove(mQObserver);
        }
        /// <summary>
        /// 通知所有的监听观察者
        /// </summary>
        public void Notify()
        {
            foreach(var i in this.observerList)
            {
                //开启每一个监听观察者的监听
                i.OpenListen();
            }
        }
    }
}
